"""
session的用法：
1. 创建session对象(实例化session对象)
    # 注意：requests.Session()为大写的S，后面的()一定不能省略
    session = requests.Session()
2. session对象发送请求
    session.get(url)
    session.post(url, headers={"k":"v"}, data={"":""})
        用法和requests发请求方式一样
3. 关闭session
    session.close()

# 1. 导包
# 2. 创建session对象
# 3. session对象发送图片验证码请求
# 4. session对象发送POST请求
# 5. 获取登陆响应的json内容
# 6. session对象发送个人订单接口请求
# 7. 打印个人订单接口响应内容的文本信息
# 8. 关闭session
"""


import requests

s = requests.Session()
image_url = 'http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify&r=0.554147'
s.get(image_url)
login_url = 'http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login'
info = {
    'username': '13344445555',
    'password': '123456',
    'verify_code': '8888'
}
response = s.post(login_url, json=info)
print(response.json())
order_url = 'http://tpshop-test.itheima.net/index.php/Home/Order/order_list.html'
response = s.get(order_url)
print(response.text)
s.close()
